package es.ats.codington.festival.daos;
/**
 */
import java.sql.Connection;

import es.ats.codington.festival.interfaces.daos.IEventDAO;
import es.ats.codington.festival.interfaces.daos.IEventSignUpDAO;
import es.ats.codington.festival.interfaces.daos.IPlaceDAO;
import es.ats.codington.festival.interfaces.daos.IVisitorDAO;
import es.ats.codington.festival.utils.FERSDataConnection;
/**
 * 
 * @author Codington_RED
 *
 */
public class ManagerDAO {

	private Connection conn;
	
	public ManagerDAO(){
		conn = FERSDataConnection.getConnection();
	}
	/**
	 * 
	 * @return conn
	 */
	public IVisitorDAO getVisitorDAO(){
		return new VisitorDAOImpl(conn);
	}
	/**
	 * 
	 * @return conn
	 */
	public IEventSignUpDAO getEventSignUpDAO(){
		return new EventSignUpDAOImpl(conn);
	}
	/**
	 * 
	 * @return conn
	 */
	public IEventDAO getEventDAO() {
		return new EventDAOImpl(conn);
	}
	/**
	 * 
	 * @return conn
	 */
	public IPlaceDAO getPlaceDAO() {
		return new PlaceDAOImpl(conn);
	}
	
	public void closeConnection(){
		FERSDataConnection.commit(conn); 
		FERSDataConnection.closeConnection(conn);
	}
	
	public void closeError(){
		FERSDataConnection.rollback(conn);
		FERSDataConnection.closeConnection(conn);
	}

	/**
	 * 
	 * @return conn
	 */
	public IEventSignUpDAO getEventSignUpDAOImpl() {
		return new EventSignUpDAOImpl(conn);
	}

	public void closeConnectionWithCommit() {
		// TODO Auto-generated method stub
		FERSDataConnection.commit(conn);
		FERSDataConnection.closeConnection(conn);
		
	}

	public void closeConnectionWithRollBack() {
		// TODO Auto-generated method stub
		FERSDataConnection.rollback(conn);
		FERSDataConnection.closeConnection(conn);
		
	}
	
}
